require("dotenv").config();
const express = require('express');
const mysql = require('mysql2/promise');
const bodyParser = require('body-parser');
const cors = require('cors');
const axios = require('axios');

const app = express();
app.use(cors());
app.use(bodyParser.json());


// 路由引入
const router = express.Router() // 根路由
const userRoute = require('./routes/user')
const infoRoute = require('./routes/info')
const honorRoute = require('./routes/honor')
const newsRoute = require('./routes/news')

// 路由挂载
router.use('/api/user', userRoute)
router.use('/api/info', infoRoute)
router.use('/api/honor', honorRoute)
router.use('/api/news', newsRoute)
app.use('/hzu_sport', router)

app.get('/', (req, res) => {
  res.send('Node.js 服务运行正常 🚀');
});

// 启动服务
app.listen(3000, () => {
  console.log('Server running at http://localhost:3000');
});
